package com.librarySystem.action;

import java.util.List;

import com.librarySystem.dto.RecordDTO;
import com.librarySystem.entity.Record;
import com.librarySystem.service.RecordServiceInterface;

public class RecordAction extends BaseLibrarySystemAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private RecordDTO recordDTO;
	private RecordServiceInterface recordService;
	private Record record;
	private List<Record> records;
	private String result;
	
	public String find(){
		records = recordService.find(recordDTO);
		if(records != null){
			return SUCCESS;
		}
		return "fail";
	}
	
	public String save(){
		if(record != null){
			if(recordService.save(record)){
				result = "借出成功";
				return "saveSuccess";
			}
		}
		result = "借出失败";
		return "saveFail";
	}
	public String savein(){
		if(record != null){
			if(recordService.savein(record)){
				result = "归还成功";
				return "saveSuccess";
			}
		}
		result = "归还失败";
		return "saveFail";
	}

	public RecordDTO getRecordDTO() {
		return recordDTO;
	}

	public void setRecordDTO(RecordDTO recordDTO) {
		this.recordDTO = recordDTO;
	}

	public RecordServiceInterface getRecordService() {
		return recordService;
	}

	public void setRecordService(RecordServiceInterface recordService) {
		this.recordService = recordService;
	}

	public Record getRecord() {
		return record;
	}

	public void setRecord(Record record) {
		this.record = record;
	}

	public List<Record> getRecords() {
		return records;
	}

	public void setRecords(List<Record> records) {
		this.records = records;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}


}
